package com.cardone.platform.common.service;

import com.cardone.platform.common.dto.EntityLogDto;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 实体日志服务
 *
 * @author yaohaitao
 */
public interface EntityLogService extends com.cardone.common.service.SimpleService<com.cardone.platform.common.dto.EntityLogDto> {
    /**
     * spring bean id
     */
    String BEAN_ID = "com.cardone.platform.common.service.EntityLogService";

    /**
     * 读取有效的实体标识
     *
     * @param id 标识
     * @return 有效的实体标识
     */
    @org.springframework.cache.annotation.Cacheable(value = BEAN_ID, key = com.cardone.common.cache.Caches.KEY_1)
    @Transactional(readOnly = true)
    String readEntityIdByIdForValid(final String id);

    /**
     * 保存:
     *
     * @param mappedClass 返回类型
     * @param save        对象
     * @return 对象
     */
    @Transactional
    <P> P saveByIdOrCode(Class<P> mappedClass, EntityLogDto save, String... selectNames);

    /**
     * 客户端标识
     *
     * @param clientId
     * @param id
     * @param dataStateCode
     * @return
     */
    @Transactional
    int updateByClient(String clientId, String id, String dataStateCode);

    /**
     * 查询 top n
     *
     * @param entityId 实体标识
     * @param topN     top n 数量
     * @return
     */
    @Transactional(readOnly = true)
    List<Map<String, Object>> findListByEntityIdAndTopN(String entityId, Integer topN);
}
